(function () {
    $.fn.extend({
        _fixednav3() {
            //固定导航栏
            class fixednav {
                constructor(el) {
                    this.el = el;
                    this.toph = this.el.height();
                    this.srcTop = 0;
                    this.nav = this.el.parent().find(".banner");

                    this.scroll();

                }
                
                scroll() {
                    $(document).scroll(() => {
                        this.srcTop = Math.ceil($(document).scrollTop());
                        if (this.srcTop > this.toph + 100) {
                            console.log(1);
                            this.el.addClass("fixed");
                            this.nav.css({
                                marginTop: this.toph + 10
                            })
                        }
                    })
                }

            }

            //tab栏
            class tabchange {
                constructor(el) {
                    this.el = el;
                    this.olis = this.el.children();
                    this.downlis=this.el.parent(".section-left").find(".tabl");
                    this.click();
                    console.log(this.downlis.eq(1));

                }
                click(){
                    let that=this;
                    this.olis.click(function(){
                        let $index = $(this).index();
                        $(this).addClass("current").siblings().removeClass("current");
                        that.downlis.eq($index).addClass("current").siblings().removeClass("current");
                    })
                }

            }
            //放大镜
            class magnifyinGlass {
                constructor(el) {
                    this.el = el;
                    this.middimg = this.el.find(".middleimg");
                    this.middarea = this.el.find(".middArea");
                    this.bigimg = this.el.find(".bigimg");
                    this.bigarea = this.el.find(".bigArea");
                    this.score = 0;
                    this.movex = 0;
                    this.movey = 0;

                    this.middarea.css(
                        {
                            width: (this.bigarea.width() / this.bigimg.width()) * this.middimg.width(),
                            height: (this.bigarea.height() / this.bigimg.height()) * this.middimg.height(),
                        }
                    )
                    this.mouseEvent();
                }
                mouseEvent() {
                    this.el.mouseenter(() => {
                        this.middarea.show();
                        this.bigarea.show();
                        this.score = this.bigarea.width() / this.middarea.width();
                    }).mouseleave(() => {
                        this.middarea.hide();
                        this.bigarea.hide();
                    })

                    this.el.mousemove((e) => {
                        this.movex = e.pageX - this.middimg.offset().left - (this.middarea.width() / 2);
                        this.movey = e.pageY - this.middimg.offset().top - (this.middarea.height() / 2);

                        //设置边界
                        if (this.movex < 0)
                            this.movex = 0
                        if (this.movex > this.middimg.width() - this.middarea.width())
                            this.movex = this.middimg.width() - this.middarea.width()
                        if (this.movey < 0)
                            this.movey = 0;
                        if (this.movey > this.middimg.height() - this.middarea.height())
                            this.movey = this.middimg.height() - this.middarea.height()
                        this.middarea.css({
                            left: this.movex,
                            top: this.movey
                        })
                        this.bigimg.css({
                            left: this.movex * this.score * -1,
                            top: this.movey * this.score * -1

                        })

                    })
                }

            }
            new fixednav($(".head"));
            new magnifyinGlass($(".info-left"))
            new tabchange($(".tab-contain"))
            new tabchange($(".tab-contain1"))
        }
    })
})()
$(window).load(function () {
    $(".head")._fixednav3();
    $(".info-left")._fixednav3();
    $(".tab-contain")._fixednav3();
    $(".tab-contain1")._fixednav3();
})
